/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ${USER}
 * Date: ${YEAR}-${MONTH}-${DAY}
 * Time: ${TIME}
 */
class Solution {
    public int removeElement(int[] nums, int val) {
        int n = nums.length;
        int slow = 0;
        for (int fast = 0; fast < n; fast++) {
            if(nums[fast] != val) {
                nums[slow] = nums[fast];
                slow++;
            }
        }
        return slow;
    }
}
public class Main {
    public static void main(String[] args) {
        int[] nums = {3,2,2,3};
        int val = 3;
        Solution solution = new Solution();
        int n = solution.removeElement(nums, val);
        for (int i = 0; i < n; i++) {
            System.out.print(nums[i] + " ");
        }
    }
}